<template>
  <div class="photoInfo">
    <h3>{{infoList.title}}</h3>
    <p class="subtitle">
      <span>发表时间:{{infoList.add_time | dateFormat}}</span>
      <span>点击:{{infoList.click}}次</span>
    </p>
    <hr />

    <!-- 缩略图区域 -->
    <div class="thumbs">
      <vue-preview :slides="slide1"></vue-preview>
    </div>
    <!-- 图片内容区域 -->
    <div class="content" v-html="infoList.content"></div>
    <!-- 评论子组件区域 -->
    <comment :id="this.id"></comment>
  </div>
</template>
 
<script>
import { Toast } from "mint-ui";
import comment from "../subcomponents/comment";
export default {
  name: "photoInfo",
  data() {
    return {
      infoList: [], //图片详情页
      id: this.$route.params.id,
      slide1: [], //缩略图数据
    };
  },
  mounted() {
    this.getPhotoInfoById();
    this.getThumbs();
  },

  methods: {
    getPhotoInfoById() {
      this.$http.get("api/getimageInfo/" + this.id).then((res) => {
        if (res.body.status === 0) {
          //   console.log(res.body);
          this.infoList = res.body.message[0];
        } else {
          Toast("图片详情加载失败 ");
        }
      });
    },
    getThumbs() {
      this.$http.get("api/getthumimages/" + this.id).then((res) => {
        if (res.body.status === 0) {
          res.body.message.forEach((item) => {
            item.w = 600;
            item.h = 400;
            item.src = item.src;
            item.msrc = item.src;
          });
          this.slide1 = res.body.message;
        }
      });
    },
  },
  components: {
    comment,
  },
};
</script>
 
<style scoped lang = "scss">
.photoInfo {
  padding: 3px;
  h3 {
    color: #26a2ff;
    font-size: 15px;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }
  .content {
    font-size: 13px;
    line-height: 30px;
  }
  /* 定义小图的样式 */
  .thumbs {
            /deep/ .my-gallery{   //deep深层作用选择器
                display: flex;
                flex-wrap:wrap;//默认换行
                figure{
                    width: 30%;
                    margin: 5px;
                    img{
                        width: 100%;
                        box-shadow: 0 0 8px #999;
                        border-radius: 5px;
                    }
                }
            }
        }

}
</style>